package cn.yangliu.nacos.management.repository.sys;

import cn.yangliu.jpa.base.repository.BaseRepository;
import cn.yangliu.nacos.management.entity.sys.Role2Authority;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-01
 */
public interface Role2AuthorityRepository extends BaseRepository<Role2Authority, Role2Authority.Role2AuthorityKey> {

    /**
     * Delete by role id.
     *
     * @param roleId the role id
     */
    @Query("delete from Role2Authority r2a where r2a.id.roleId=:roleId")
    @Modifying
    void deleteByRoleId(Long roleId);

    /**
     * Delete by authority id.
     *
     * @param authorityId the authority id
     */
    @Query("delete from Role2Authority r2a where r2a.id.authorityId=:authorityId")
    @Modifying
    void deleteByAuthorityId(Long authorityId);
}
